package ihm;

import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

import model.value.VersionnedValue;

/**
 * Implémentation de l'interface DisplayerPanel, basée sur la bilbiothèque Swing.
 */
public class DisplayerPanelImpl extends JPanel implements DisplayerPanel {

	private static final long serialVersionUID = 4505501974901228648L;
	
	private static int nbDisplayer = 0;
	
	private JLabel name;
	private JLabel valueText;
	private JLabel valueLabel;
	private JLabel versionText;
	private JLabel versionLabel;
	
	public DisplayerPanelImpl() {
		super();

		nbDisplayer++;
		
		setLayout(new FlowLayout());
		
		name = new JLabel("Afficheur " + (nbDisplayer) + " - ");
		valueText = new JLabel("Value : ");
		valueLabel = new JLabel();
		versionText = new JLabel(" Version : ");
		versionLabel = new JLabel();
		
		add(name);
		add(valueText);
		add(valueLabel);
		add(versionText);
		add(versionLabel);
	}
	
	@Override
	public void displayValue(VersionnedValue value) {
		valueLabel.setText(value.getValue() + "");
		versionLabel.setText(value.getVersion() + "");
	}

}
